//
//  NetworkManger.m
//  DeepBreathing
//
//  Created by rimi on 15/12/16.
//  Copyright © 2015年 rimi. All rights reserved.
//

#import "NetworkManger.h"
#import "AFHTTPSessionManager.h"
#import "UserModel.h"

@implementation NetworkManger

+(void)postWithUrl:(NSString *)url params:(NSDictionary *)params successHander:(SuccessHander)success failureHander:(FailureHander)failure{
    
    AFHTTPSessionManager *manger = [AFHTTPSessionManager manager];
    [manger POST:[BASE_URL stringByAppendingString:url] parameters:params success:^(NSURLSessionDataTask * _Nonnull task, id  _Nonnull responseObject) {
        
        if (success) {
            success(responseObject);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failure) {
            failure(error);
        }
        
    }];
    
    
}

+(NSDictionary *)parasByappendingUserInfo:(NSDictionary *)params
{
    
//    NSMutableDictionary *retParams = [params mutableCopy];
//    
//    retParams[@"userId"] = [UserModel defaultUser].userID;
//    
//    retParams[@"phone"] = [UserModel defaultUser].phoneNumber;
//    
//    retParams[@"token"] = [UserModel defaultUser].token;
//    
//    retParams[@"password"] = [UserModel defaultUser].password;
//    
//    return retParams;
    
    UserModel *user = [UserModel defaultUser];
    NSMutableDictionary *defaultInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"userId":user.userID , @"phone":user.phoneNumber,@"password":user.password,@"token":user.token}];
    
    [defaultInfo addEntriesFromDictionary:params];
    
    return defaultInfo;
    
    }

@end
